package org.particlethink.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.particlethink.entry.PlanStatus;
import org.particlethink.model.BatchPlan;

import java.util.Date;
import java.util.List;

@Mapper
public interface BatchPlanMapper extends tk.mybatis.mapper.common.Mapper<BatchPlan> {
    @Select("select * from batch_plans where master_plan_id = #{masterPlanID}")
    List<BatchPlan> selectAllByMasterPlanID(@Param("masterPlanID") int masterPlanID);


    @Select("select * from batch_plans where master_plan_id = #{masterPlanID} and status = #{status}")
    List<BatchPlan> selectAllByMasterPlanIDAndStatus(@Param("masterPlanID") int masterPlanID, @Param("status") PlanStatus status);

    @Select("select * from batch_plans limit  #{limit} offset #{offset}")
    List<BatchPlan> selectByPagination(@Param("offset") int offset, @Param("limit") int limit);

    List<BatchPlan> selectBatchPlans(
        @Param("projectIds") List<Integer> projectIds,
        @Param("status") PlanStatus status,
        @Param("createAtStart") Date createAt,
        @Param("createAtEnd") Date createAtEnd,
        @Param("submitAtStart") Date submitAtStart,
        @Param("submitAtEnd") Date submitAtEnd,
        @Param("deadlineStart") Date deadlineStart,
        @Param("deadlineEnd") Date deadlineEnd,
        @Param("categoryIds") List<String> categoryIds,
        @Param("masterPlanNo") String masterPlanNo,
        @Param("batchPlanNo") String batchPlanNo
    );

    List<BatchPlan> selectByDuration(@Param("startAt") Date startAt, @Param("endAt") Date endAt);


    List<BatchPlan> selectByMasterPlanID(@Param("masterPlanID") int masterPlanID);

}
